import { SelectControlSchema } from 'amis/lib/renderers/Form/Select'
import serverSelectUtils, { ServerSelectUtilsProps } from '@/components/amis/ServerSelectUtils/serverSelectUtils'
import upmsAdminApiConfig from '@/core/upms/generated/apiconfig/upmsAdminApiConfig'

class UpmsAppIdSelectUtils {
	getSchema = (parmas?: Partial<ServerSelectUtilsProps>): SelectControlSchema => {
		const mergeProps = Object.assign(
			{
				label: '账户应用',
				name: 'upmsAppId',
				labelField: '权限应用',
				valueField: 'id',
				searchField: 'title',
				detailApiConfig: upmsAdminApiConfig.upmsApplication.get,
				searchApiConfig: upmsAdminApiConfig.upmsApplication.search,
			} as ServerSelectUtilsProps,
			parmas,
		)
		return serverSelectUtils.getSchema(mergeProps)
	}
}

export default new UpmsAppIdSelectUtils()
